package com.ruoyi.common.core;

import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class MapUtil {
    //正序排列
    static class MapKeyComparator implements Comparator<Integer> {
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1 - o2;
        }
    }

    public static Map<Integer, List<BigDecimal>> sortMapByKey(Map<Integer, List<BigDecimal>> map) {
        if (map == null || map.isEmpty()) {
            return null;
        }
        Map<Integer, List<BigDecimal>> sortMap = new TreeMap<>(new MapKeyComparator());
        sortMap.putAll(map);
        return sortMap;
    }
}
